home *** CD-ROM | disk | FTP | other *** search
/ Singles Flirt Up Your Life! (German) / Singles Flirt Up Your Life.iso / data1.cab / Statemachine / subwalk.lua < prev    next >
Text File  |  2004-01-29  |  3KB  |  150 lines

  1. -- subwalk state machine
  2.  
  3. beginStateMachine()
  4.  
  5.     onEnter(function(msg)
  6.         print("subwalk onEnter ---------------");
  7.     end )
  8.     
  9.     onExit(function(msg)
  10.         print("subwalk onExit ----------------");
  11.     end )
  12.  
  13.     
  14.     -- stand
  15.     state("stand")
  16.         onEnter(function(msg)
  17.             -- mission test
  18.             getParent().getGameObjectServer().mission.sendMsgThis("checkComplete");
  19.             setPose(archize(getParent(), "stand1"));
  20.             
  21.         end )
  22.  
  23.         onMsg("end", function(msg)
  24.             setDelayedState("stand2", random(1000, 3000));
  25.             actionComplete();
  26.         end )    
  27.  
  28.     state("stand2")
  29.         onEnter(function(msg)
  30.             setPose(archize(getParent(), "stand2"));
  31.         end )
  32.         
  33.         onMsg("end", function(msg)
  34.             setDelayedState("stand3", random(1000, 3000));
  35.             actionComplete();
  36.         end )    
  37.  
  38.     state("stand3")
  39.         onEnter(function(msg)
  40.             setPose(archize(getParent(), "stand3"));
  41.         end )
  42.         
  43.         onMsg("end", function(msg)
  44.             setDelayedState("stand4", random(1000, 3000));
  45.             actionComplete();
  46.         end )    
  47.         
  48.     state("stand4")
  49.         onEnter(function(msg)
  50.             setPose(archize(getParent(), "stand4"));
  51.         end )
  52.         
  53.         onMsg("end", function(msg)
  54.             setDelayedState("stand", random(1000, 3000));
  55.             actionComplete();
  56.         end )
  57.         
  58.                     
  59.         
  60.     -- walk
  61.     state("walk")
  62.         onEnter(function(msg)
  63.             -- if distance to walk is greater 4m, run
  64.             if isRunDistance() then
  65.                 setState("runRFF-runLFF");
  66.             else
  67.                 local c = getParent();
  68.                 startWalk(archizeWalk(c, "stand-walkLFF-"), archizeWalk(c, "stand-walkLFF-"), WALK_SPEEDUP);
  69.             end
  70.         end )
  71.  
  72.         onMsg("next", function(msg)
  73.             setState("walkLFF-walkRFF");
  74.         end )    
  75.         
  76.         onMsg("end", function(msg)
  77.             exitStateMachine();
  78.         end )    
  79.  
  80.     state("walkRFF-walkLFF")
  81.         onEnter(function(msg)
  82.             if isRunDistance() then
  83.                 setState("runRFF-runLFF");
  84.             else
  85.                 local c = getParent();
  86.                 startWalk(archizeWalk(c, "walkRFF-walkLFF-"), archizeWalk(c, "walkRFF-stand-"), WALK_SPEEDUP);
  87.                 createDirt(DIRT_FOOTSTEP, WALK_DIRT_SIZE, WALK_DIRT_PROBABILITY);
  88.                 makeStepSound();
  89.             end
  90.         end )
  91.  
  92.         onMsg("next", function(msg)
  93.             setState("walkLFF-walkRFF");
  94.         end )    
  95.         
  96.         onMsg("end", function(msg)
  97.             exitStateMachine();
  98.         end )    
  99.  
  100.     state("walkLFF-walkRFF")
  101.         onEnter(function(msg)
  102.             local c = getParent();
  103.             startWalk(archizeWalk(c, "walkLFF-walkRFF-"), archizeWalk(c, "walkLFF-stand-"), WALK_SPEEDUP);
  104.             makeStepSound();
  105.         end )
  106.  
  107.         onMsg("next", function(msg)
  108.             setState("walkRFF-walkLFF");
  109.         end )    
  110.         
  111.         onMsg("end", function(msg)
  112.             exitStateMachine();
  113.         end )    
  114.  
  115.     -- run
  116.     state("runRFF-runLFF")
  117.         onEnter(function(msg)
  118.             local c = getParent();
  119.             startWalk(archizeWalk(c, "runRFF-runLFF-"), archizeWalk(c, "walkRFF-stand-"), RUN_SPEEDUP);
  120.             createDirt(DIRT_FOOTSTEP, WALK_DIRT_SIZE, WALK_DIRT_PROBABILITY);
  121.             makeStepSound();
  122.         end )
  123.  
  124.         onMsg("next", function(msg)
  125.             setState("runLFF-runRFF");
  126.         end )    
  127.         
  128.         onMsg("end", function(msg)
  129.             exitStateMachine();
  130.         end )    
  131.  
  132.     state("runLFF-runRFF")
  133.         onEnter(function(msg)
  134.             local c = getParent();
  135.             startWalk(archizeWalk(c, "runLFF-runRFF-"), archizeWalk(c, "walkLFF-stand-"), RUN_SPEEDUP);
  136.             createDirt(DIRT_FOOTSTEP, WALK_DIRT_SIZE, WALK_DIRT_PROBABILITY);
  137.             makeStepSound();
  138.         end )
  139.  
  140.         onMsg("next", function(msg)
  141.             setState("runRFF-runLFF");
  142.         end )    
  143.         
  144.         onMsg("end", function(msg)
  145.             exitStateMachine();
  146.         end )    
  147.     
  148.         
  149. endStateMachine()
  150.